<?php require_once("includes/security.php"); ?>
<?php 
require_once("includes/initializeSession.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="JavaScript" type="text/javascript" src="Script/jquery-1.9.1.js"></script>
  <script language="JavaScript" type="text/javascript" src="Script/jquery-ui-1.10.3.custom.js"></script>
  <link rel="stylesheet" type="text/css" href="css/jquery-ui-1.10.3.custom.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript">
function handleClick(img) {
 $("#productName").text("שם :" +img.getAttribute("title"));
 $("#productDesc").text("תיאור :" +img.getAttribute("description") );
 $("#productPrice").text("מחיר :" +img.getAttribute("price"));
var productid=img.getAttribute("productid");
$("#productid").val(productid);
preview.src=img.src;
$("#Pname").val(img.getAttribute("title"));
$("#Pdesc").val(img.getAttribute("description"));
$("#Pprice").val(img.getAttribute("price"));

		
}

$(document).ready(function() {
   $("#first").click();
    $("#deliveryDate" ).datepicker({
		dateFormat: 'yy-mm-dd',
	});
	
	
  $('#deliveryDate').datepicker('setDate', '+0');
});
</script>
<link rel="stylesheet" type="text/css" href="css/style.css">
<title>קליניקה נטורופתית</title>
<?php
require("includes/openConnection.php");
if(isset($_POST['submit'])  )
{
$time_now=date("Y-m-d H:i:s");
if(mysql_query("INSERT INTO orders (`id`, `users_username`, `created`, `delivery`, `state`, `fn`, `ln`, `address`, `email`, `phone`, `orderType`, `note`, `Pname`, `Pdesc`, `Pprice`) VALUES (NULL, '{$_SESSION['UserName']}', '{$time_now}', '{$_POST['deliveryDate']}', '0', '{$_POST['fn']}', '{$_POST['ln']}', '{$_POST['address']}', '{$_POST['email']}', '{$_POST['phone']}', '0', '{$_POST['note']}', '{$_POST['Pname']}', '{$_POST['Pdesc']}', '{$_POST['Pprice']}');"))
echo "הזמנה נרשמה במערכת";
else
echo "תקלה ברישום ההזמנה";
}

require("includes/closeConnection.php");
?>
</head>

<body>
<container id="container">
  <?php require("header.php"); ?>
      <content id="content">
      <contentTitle id="contentTitle">
      הצמחים והטיפולים שלנו
      </contentTitle>
      <contentText id="contentText">
<center>
<?php   if (!isset($_SESSION['UserName'])) {?>
<h1  style=" color:#F00"  > אנא התחבר למערכת אם ברצונך לבצע הזמנות </h1>
<?php }?>
<h1  style="display:inline; color:#66F" id="productName" > titleeee </h1>
<h3  style=" vertical-align:top; color:#3FF;" id="productDesc"> desc </h3>
<h4  style=" vertical-align:top;color:#3FF;" id="productPrice">
price
</h3>
<img style=" vertical-align:top;display:inline;"  width="400" height="400" higet name="preview" src="" alt=""/>
<div  class="thumbnails" >
  <?php 	
require("includes/openConnection.php");
$result = mysql_query("SELECT * FROM `product` where visible =1")or die ('אין דף כזה'.mysql_error());
if(mysql_num_rows($result) > 0)
{
			while($row = mysql_fetch_array($result))
			{	
			$id=$row['id'];
			$name=$row['name'];
			$description=$row['description'];
			$price=$row['price'];		
			$pic_path=$row['pic_path'];
			$visible=$row['visible'];
			echo "<img width=100 height=100 id=first  onclick=handleClick(this);  src=".$pic_path." alt='$name' title='$name' productName='$name' description='$description' price='$price' productid='$id' />";
			}
}
require("includes/closeConnection.php");
?>
</div>
<form action="" method="POST" >
<table id="delivry">
      <tr bgcolor="#FFFFFF">
    <td>שם פרטי</td>
    <td>שם משפחה</td>
    <td>מייל</td>
    <td>טלפון</td>
    <td>כתובת</td>
    <td>תאריך שליחה</td>
    <td>הערות</td>
 
  </tr>
      <tr >
    <td><input type="text" name="fn"  id="fn" /></td>
    <td><input type="text" name="ln"   id="ln" /></td>
    <td><input type="text" name="email"  id="email" /></td>
    <td><input type="text" name="phone"  id="phone" /></td>
    <td><input type="text" name="address"   id="address" /></td>
   
    <td>  <input type="text" name="deliveryDate" id="deliveryDate" /></td>
    
    <td><textarea rows="4" cols="15" name="note" id="note"  > </textarea ></td>

  </tr>
  <tr>
  <td>
   <input type="hidden" value="1" name="Pname" id="Pname">
 <input type="hidden" value="1" name="Pdesc" id="Pdesc">
 <input type="hidden" value="1" name="Pprice" id="Pprice">
<input  type="submit" id="submit" name="submit" value="שלח"/>
  </td>
  </tr>
 </table>

</form> 
</contentText>
      </content>
</container>
    
     
    
</body>
</html>
